#!/bin/bash
clear

if [[ "$EUID" -ne 0 ]]; then
    echo -e "${ERROR} RALAT ${RESET}${TEXT} Script need to be run as root! ${RESET}" && exit 1
fi

TEXT='\033[30;107;2m'
INFO='\033[97;44m'
WARNING='\033[97;43m'
ERROR='\033[97;41m'
SUCCESS='\033[97;42m'

GREEN='\033[92m'
YELLOW='\033[93m'
RESET='\033[0m'

echo
echo -e "${TEXT} DROPBEAR & OPENVPN                                         ${RESET}"
echo
echo -e "[01] ${GREEN}trial${RESET}          - ${YELLOW}Buat akaun percubaan${RESET}"
echo -e "[02] ${GREEN}create${RESET}         - ${YELLOW}Tambah akaun pengguna${RESET}"
echo -e "[03] ${GREEN}renew${RESET}          - ${YELLOW}Perbaharui akaun pengguna${RESET}"
echo -e "[04] ${GREEN}login${RESET}          - ${YELLOW}Senarai pengguna log masuk${RESET}"
echo -e "[05] ${GREEN}lists${RESET}          - ${YELLOW}Senaraikan akaun pengguna${RESET}"
echo -e "[06] ${GREEN}lock${RESET}           - ${YELLOW}Kunci/Lumpuhkan akaun pengguna${RESET}"
echo -e "[07] ${GREEN}unlock${RESET}         - ${YELLOW}Buka kunci/Dayakan akaun pengguna${RESET}"
echo -e "[08] ${GREEN}delete${RESET}         - ${YELLOW}Padam akaun pengguna${RESET}"
echo
echo -e "${TEXT} SHADOWSOCKS-LIBEV                                          ${RESET}"
echo
echo -e "[09] ${GREEN}add-ss${RESET}         - ${YELLOW}Tambah akaun pengguna${RESET}"
echo -e "[10] ${GREEN}renew-ss${RESET}       - ${YELLOW}Perbaharui akaun pengguna${RESET}"
echo -e "[11] ${GREEN}list-ss${RESET}        - ${YELLOW}Senaraikan akaun pengguna${RESET}"
echo -e "[12] ${GREEN}enable-ss${RESET}      - ${YELLOW}Buka kunci/Dayakan akaun pengguna${RESET}"
echo -e "[13] ${GREEN}disable-ss${RESET}     - ${YELLOW}Kunci/Lumpuhkan akaun pengguna${RESET}"
echo -e "[14] ${GREEN}delete-ss${RESET}      - ${YELLOW}Padam akaun pengguna${RESET}"
echo
echo -e "${TEXT} V2RAY & XRAY                                               ${RESET}"
echo
echo -e "[15] ${GREEN}add-v2ray${RESET}         - ${YELLOW}Tambah akaun pengguna${RESET}" # ERROR
echo -e "[16] ${GREEN}renew-v2ray${RESET}       - ${YELLOW}Perbaharui akaun pengguna${RESET}" # ERROR
echo -e "[17] ${GREEN}list-v2ray${RESET}        - ${YELLOW}Senaraikan akaun pengguna${RESET}" # ERROR
echo -e "[18] ${GREEN}del-v2ray${RESET}         - ${YELLOW}Padam akaun pengguna${RESET}" # ERROR
echo
echo -e "[19] ${GREEN}add-xray${RESET}         - ${YELLOW}Tambah akaun pengguna${RESET}" # ERROR
echo -e "[20] ${GREEN}renew-xray${RESET}       - ${YELLOW}Perbaharui akaun pengguna${RESET}" # ERROR
echo -e "[21] ${GREEN}list-xray${RESET}        - ${YELLOW}Senaraikan akaun pengguna${RESET}" # ERROR
echo -e "[22] ${GREEN}del-xray${RESET}         - ${YELLOW}Padam akaun pengguna${RESET}" # ERROR
echo
echo -e "${TEXT} WIREGUARD                                                  ${RESET}"
echo
echo -e "[23] ${GREEN}add-wg${RESET}         - ${YELLOW}Tambah akaun pengguna${RESET}" # ERROR
echo -e "[24] ${GREEN}renew-wg${RESET}       - ${YELLOW}Perbaharui akaun pengguna${RESET}" # ERROR
echo -e "[25] ${GREEN}list-wg${RESET}        - ${YELLOW}Senaraikan akaun pengguna${RESET}" # ERROR
echo -e "[26] ${GREEN}del-wg${RESET}         - ${YELLOW}Padam akaun pengguna${RESET}" # ERROR
echo
echo -e "${TEXT} SERVICES                                                   ${RESET}"
echo
echo -e "[27] ${GREEN}dropbear${RESET}       - ${YELLOW}Menu perkhidmatan Dropbear${RESET}"
echo -e "[28] ${GREEN}openvpn${RESET}        - ${YELLOW}Menu perkhidmatan OpenVPN${RESET}"
echo -e "[29] ${GREEN}sslibev${RESET}        - ${YELLOW}Menu perkhidmatan Shadowsocks${RESET}"
echo -e "[30] ${GREEN}v2ray${RESET}          - ${YELLOW}Menu perkhidmatan V2ray${RESET}" # ERROR
echo -e "[31] ${GREEN}xray${RESET}           - ${YELLOW}Menu perkhidmatan Xray${RESET}" # ERROR
echo -e "[32] ${GREEN}wireguard${RESET}      - ${YELLOW}Menu perkhidmatan Wireguard${RESET}" # ERROR
echo -e "[33] ${GREEN}ohpserver${RESET}      - ${YELLOW}Menu perkhidmatan OHPServer${RESET}" # ERROR
echo -e "[34] ${GREEN}websocket${RESET}      - ${YELLOW}Menu perkhidmatan WebSocket${RESET}" # ERROR
echo -e "[35] ${GREEN}squid${RESET}          - ${YELLOW}Menu perkhidmatan Squid3${RESET}"
echo -e "[36] ${GREEN}tinyproxy${RESET}      - ${YELLOW}Menu perkhidmatan TinyProxy${RESET}" # ERROR
echo -e "[37] ${GREEN}stunnel${RESET}        - ${YELLOW}Menu perkhidmatan Stunnel4${RESET}"
echo
echo -e "${TEXT} SERVER                                                     ${RESET}"
echo
echo -e "[38] ${GREEN}detail${RESET}         - ${YELLOW}Tunjukkan perincian server${RESET}" # WARNING
echo -e "[39] ${GREEN}tcpbbr${RESET}         - ${YELLOW}Tweak Protocol TCP BBR${RESET}"
echo -e "[40] ${GREEN}shaper${RESET}         - ${YELLOW}Hadkan muat turun/muat naik${RESET}"
echo -e "[41] ${GREEN}restore${RESET}        - ${YELLOW}Pemulihan sandaran fail${RESET}" # ERROR
echo -e "[42] ${GREEN}backup${RESET}         - ${YELLOW}Fail pelayan sandaran${RESET}" # ERROR
echo -e "[43] ${GREEN}speedtest${RESET}      - ${YELLOW}Uji kelajuan pelayan${RESET}"
echo
echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
echo -e "${TEXT} Dicipta oleh Doctype, Dikuasakan oleh Cybertize.           ${RESET}"
echo -e "${TEXT} Hak Cipta 2021, Hak Cipta Terpelihara.                     ${RESET}"
echo -e "${TEXT} ========================================================== ${RESET}"
echo

read -p "Masukkan pilihan anda atau exit untuk keluar: " _choice
case $_choice in
# sshd & openvpn
    01|trial )
        bash /usr/local/plugins/trial.sh
    ;;
    02|create )
        bash /usr/local/plugins/create.sh
    ;;
    03|renew )
        bash /usr/local/plugins/renew.sh
    ;;
    04|login )
        bash /usr/local/plugins/login.sh
    ;;
    05|lists )
        bash /usr/local/plugins/lists.sh
    ;;
    06|lock )
        bash /usr/local/plugins/lock.sh
    ;;
    07|unlock )
        bash /usr/local/plugins/unlock.sh
    ;;
    08|delete )
        bash /usr/local/plugins/delete.sh
    ;;
# shadowsocks
    09|add-ss )
        bash /usr/local/plugins/add-ss.sh
    ;;
    10|renew-ss )
        bash /usr/local/plugins/renew-ss.sh
    ;;
    11|list-ss )
        bash /usr/local/plugins/lists-ss.sh
    ;;
    12|enable-ss )
        bash /usr/local/plugins/enable-ss.sh
    ;;
    13|disable-ss )
        bash /usr/local/plugins/disable-ss.sh
    ;;
    14|delete-ss )
        bash /usr/local/plugins/delete-ss.sh
    ;;
# v2ray
    15|add-v2ray )
        bash /usr/local/plugins/add-v2ray.sh # ERROR
    ;;
    16|renew-v2ray )
        bash /usr/local/plugins/renew-v2ray.sh # ERROR
    ;;
    17|list-v2ray )
        bash /usr/local/plugins/lists-v2ray.sh # ERROR
    ;;
    18|del-v2ray )
        bash /usr/local/plugins/delete-v2ray.sh # ERROR
    ;;
# xray
    19|add-xray )
        bash /usr/local/plugins/add-xray.sh # NOT EXIST
    ;;
    20|renew-xray )
        bash /usr/local/plugins/renew-xray.sh # NOT EXIST
    ;;
    21|list-xray )
        bash /usr/local/plugins/lists-xray.sh # NOT EXIST
    ;;
    22|del-xray )
        bash /usr/local/plugins/delete-xray.sh # NOT EXIST
    ;;
# wireguard
    23|add-wg )
        bash /usr/local/plugins/add-wg.sh # ERROR
    ;;
    24|renew-wg )
        bash /usr/local/plugins/renew-wg.sh # ERROR
    ;;
    25|list-wg )
        bash /usr/local/plugins/lists-wg.sh # ERROR
    ;;
    26|del-wg )
        bash /usr/local/plugins/delete-wg.sh # ERROR
    ;;
# service
    27|dropbear )
        bash /usr/local/plugins/dropbear.sh
    ;;
    28|openvpn )
        bash /usr/local/plugins/openvpn.sh
    ;;
    29|sslibev )
        bash /usr/local/plugins/sslibev.sh # ERROR
    ;;
    30|v2ray )
        bash /usr/local/plugins/v2ray.sh # ERROR
    ;;
    31|xray )
        bash /usr/local/plugins/xray.sh # NOT EXIST
    ;;
    32|wireguard )
        bash /usr/local/plugins/wireguard.sh # ERROR
    ;;
    33|ohpserver )
        bash /usr/local/plugins/ohpserver.sh # NOT EXIST
    ;;
    34|websocket )
        bash /usr/local/plugins/websocket.sh # NOT EXIST
    ;;
    35|squid )
        bash /usr/local/plugins/squid.sh # WARNING
    ;;
    36|tinyproxy )
        bash /usr/local/plugins/tinyproxy.sh # WARNING
    ;;
    37|stunnel )
        bash /usr/local/plugins/stunnel.sh # WARNING
    ;;
# server
    38|detail )
        bash /usr/local/plugins/detail.sh # WARNING
    ;;
    39|tcpbbr )
        bash /usr/local/plugins/tcpbbr.sh
    ;;
    40|shaper )
        bash /usr/local/plugins/wondershaper.sh
    ;;
    41|restore )
        bash /usr/local/plugins/restore.sh # ERROR
    ;;
    42|backup )
        bash /usr/local/plugins/backup.sh # ERROR
    ;;
    43|speedtest )
        speedtest
    ;;
    00|quit )
        clear; exit 0
    ;;
    * )
        echo
        echo -e "${ERROR} RALAT ${RESET}${TEXT} Pilihan tidak sah! ${RESET}"
        echo
        menu
    ;;
esac
